package com.masterclient.app.businessmodule.settingmodule.auth.contract;

import android.net.Uri;

import com.eoner.common.config.Config;
import com.eoner.managerlibrary.netsign.NetEnvManager;
import com.masterclient.app.httpservice.RetrofitUtil;
import com.masterclient.app.businessmodule.minemodule.point.model.PointDrawBean;

import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;

public class PointDrawContractPresenter extends PointDrawContract.Presenter {

    @Override
    public void getPointDrawData(String code) {


        String url = NetEnvManager.BASE_SURL+"api/product/integral_list?version=" + Config.URL_VERSION;

        mRxManager.add(toSubscribe(RetrofitUtil.getInstance().drawPointBean(Uri.encode(Uri.encode(code,"%")),"" + Config.URL_VERSION), new Consumer<PointDrawBean>() {
            @Override
            public void accept(PointDrawBean bean) throws Exception {
                if ("0".equals(bean.getCode())){
                    mView.showData(bean.getData());
                }else {
                    mView.loadFail(bean.getMsg());
                }
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(@NonNull Throwable o) throws Exception {
                o.printStackTrace();
                mView.loadFail(o.getMessage());
            }
        }));


    }
}
